EasyCoding.uz

Courses / C++ Learning / Loops

Loops

Mark as Complete

Repeat actions with for, while, and do-while.

Loop Types

  • for is best when you know the count.
  • while runs while a condition is true.
  • do-while runs at least once.
Key takeaway: use loops to reduce repetition.

Example

for (int i = 0; i < 3; i++) {
  std::cout << i << "\n";
}

Ready to try it yourself?

Loop through an array and print values.

← Arrays Pointers →